package xiangya.bysj.online;

import java.util.Iterator;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import xiangya.bysj.util.PropertyUtil;

@Component
public class TaskTimer {
	private static final int TIMES;

	static {
		TIMES = 3;
	}
	

	@Scheduled(fixedRate =  1000 * 60)
	public void doWork() throws Exception {
		// 必须要锁住linkedlist
		synchronized (Keeper.getKeeper()) {

			Iterator<OnlineDoctor> iter = Keeper.iterator();

			while (iter.hasNext()) {
				OnlineDoctor ol = iter.next();
				ol.setCount(ol.getCount() + 1);
				// 如果超过TIMES次,删除
				if (ol.getCount() > TIMES) {
					iter.remove();
				 }
			}

		}

	}

}
